<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{{$pageConf['title']}}</title>
<script type="text/javascript" src="Template/jquery/jquery-1.7.2.min.js"></script>
<!--js文件-->
<?php $js = explode('|', $pageConf['js']);
	foreach ($js as $k => $j) { ?>
	<script src="Template/javascript/{{$j}}.js" type="text/javascript"></script>
<?php } ?>
<!--css文件-->
<?php $css = explode('|', $pageConf['css']);
	foreach ($css as $k => $c) { ?>
	<link rel="stylesheet" href="Template/css/{{$c}}.css">
<?php } ?>

<!--异步修改购物车商品当数量里边的值发生改变的时候发送异步-->
<script type="text/javascript">
	$(function(){
		$("input[name='shul']").change(function(){
			var shuliang = $(this).val();//商品数量			
			var sid = $(this).siblings('.hiddenSid').val();//商品sid	
			var total = $(this).siblings('.danjia').val();//商品单价
			$(this).parents('div').siblings('.search_shopping_erji2').find('em i').html(total*shuliang);
				$.ajax({
					type:"post",
					url:"{{U('Index/edit')}}",
					data:{shuliang : shuliang,sid:sid},//请求数据
					dataType:'json',//数据类型
					success:function(phpData){
							$('.search_shopping_paymoney span').html(phpData);
							$('.jiesuan span em').html(phpData);
					}
				});	

		});					
	})
</script>
<!--异步修改购物车商品结束-->
<script type="text/javascript">
	$(function(){		
		$('a.add').click(function(){
			var sid = $(this).siblings('.hiddenSid').val();//商品sid	
			var i =$(this).siblings('.shul').val();//现在的数量i
			i++;//没单击一次i自增1
			if(i<100){
				$(this).siblings('.shul').val(i);//将自增之后的值赋值回去
				var shuliang = $(this).siblings('.shul').val();//点击增加以后再获得当前val值
				var total = $(this).siblings('.danjia').val();//商品单价
				$(this).parents('div').siblings('.search_shopping_erji2').find('em i').html(total*shuliang);//再把计算后的商品总价赋值			
					$.ajax({
						type:"post",
						url:"{{U('Index/edit')}}",
						data:{shuliang : shuliang,sid:sid},//请求数据
						dataType:'json',//数据类型
						success:function(phpData){
							$('.search_shopping_paymoney span').html(phpData);
							$('.jiesuan span em').html(phpData);
						}
					});	
			}				
		})
		//点击减号单机事件
		$('a.mul').click(function(){
			var sid = $(this).siblings('.hiddenSid').val();//商品sid	
			var i =$(this).siblings('.shul').val();//现在的数量i	
			i--;
			if(i>0){
				$(this).siblings('.shul').val(i);//将自增之后的值赋值回去
				var shuliang = $(this).siblings('.shul').val();//点击减号以后再获得当前val值
				var total = $(this).siblings('.danjia').val();//商品单价
				$(this).parents('div').siblings('.search_shopping_erji2').find('em i').html(total*shuliang);//再把计算后的商品总价赋值
					$.ajax({
						type:"post",
						url:"{{U('Index/edit')}}",
						data:{shuliang : shuliang,sid:sid},//请求数据
						dataType:'json',//数据类型
						success:function(phpData){
							$('.search_shopping_paymoney span').html(phpData);
							$('.jiesuan span em').html(phpData);
						}
					});	
			}
			
	    })
	})
</script>
<!--点击加减异步修改-->
<!--异步删除一个商品-->
<script type="text/javascript">
	$(function(){
		$('.delOneCart').click(function(){
			var sid = $(this).parents('p').siblings('.search_shopping_erji3').find('.hiddenSid').val();//商品sid	
			var shuliang = $(this).parents('p').siblings('.search_shopping_erji3').find('.shul').val();//商品数量
			var xiaoji = $(this).parents('p').siblings('.search_shopping_erji2').find('em i').html();//商品小计
			$(this).parents('li').remove();//把当前li移除
			$.ajax({
						type:"post",
						url:"{{U('Index/delOneCart')}}",
						data:{shuliang : shuliang,sid:sid,xiaoji:xiaoji},//请求数据
						dataType:'json',//数据类型
						success:function(phpData){
							$('.search_shopping_paymoney span').html(phpData);
							$('.jiesuan span em').html(phpData);
						}
			});
			$.ajax({
						type:"post",
						url:"{|U:'Index/Index/delOneCart'}",
						data:{shuliang : shuliang,sid:sid,xiaoji:xiaoji},//请求数据
						dataType:'json',//数据类型
						success:function(phpData){
							
						}
			});	
		})
	})
</script>
<!--异步删除一个商品结束-->
</head>
<body>
	<!--顶部导航-->
	<div id="top_nav">
		<div class="top_ad_center">
			<div class="num1">
				<a href="{{U('Index/index')}}">时尚商城</a>
			</div>

			<!--右侧-->
			<div class="top_ad_right">
				{{if value="isset($_SESSION['username'])"}}
					<div class="top_ad_right1">
						<span>您好，{{substr($_SESSION['username'],0,-7)}}</span>
						<a href="{{U('Public/out')}}" style="color: #666666;" class="out">退出登录</a>
					</div>
				{{else}}
					<div class="top_ad_right1">
						<a href="{{U('Public/login')}}">登陆</a>
						<a href="{{U('Public/reg')}}">注册</a>
					</div>
				{{endif}}
				<div class="top_ad_right2">
					{{if value="isset($_SESSION['username'])"}}
						<a href="{{U('MineYG/index')}}">我的优购</a>
					{{else}}
						<a href="{{U('Public/login')}}">我的优购</a>
					{{endif}}					
				</div>
				<div class="top_ad_right2">
					{{if value="isset($_SESSION['username'])"}}
						<a href="{{U('MineYG/order')}}">我的订单</a>
					{{else}}
						<a href="{{U('Public/login')}}">我的订单</a>
					{{endif}}
				</div>

			</div>
			<!--右侧结束-->
		</div>		
	</div>
	<!--顶部导航结束-->
	<!--搜索区域-->
	<div id="search">
		<!--搜索大区域-->
		<div class="search_center">
			<!--优购logo-->
			<div class="logo">
				<a href="{{U('Index/index')}}"><img src="TEMPLATE/images/logo.jpg"/></a>
			</div>
			<!--优购logo结束-->
			<!--form搜索区域-->
			<form action="" method="post">
				<div class="form_left"></div>
				<div class="input_search">
					<input type="text" name="keyword" id="" value=""/>
				</div>
				<div class="form_left"></div>
				<div class="search_btn">
				</div>
			</form>
			<!--form区域结束-->
			<!--热门搜索-->
			<div class="search_hot">
				{{foreach from="$data" key="$k" value="$v"}}
				|<a href="{{U('List/index',array('cid'=>$v['cid']))}}">&nbsp;{{$v['cname']}}</a>
				{{endforeach}}
			</div>
			<!--热门搜索区域结束-->
			<!--购物车-->
			<div class="search_shopping">
				<a href="{{U('MyCart/index')}}">
					<div class="search_shopping_logo"></div>
					<div class="search_shopping_paymoney">
						购物车(
						{{if value="isset($_SESSION['cart'])"}}
						<span>{{$cart}}</span>
						{{else}}
						<span>0</span>
						{{endif}}
						)件													
					</div>
					<div class="search_shopping_sanjiao"></div>																
				</a>
				
				{{if value="isset($_SESSION['cart'])"}}
					<?php
						$goods = $_SESSION['cart']['goods'];
					?>
					<div class="search_shopping_erji">
						<ul>
							{{foreach from="$goods" key="$k" value="$v"}}
							<li>
								<div class="img">
									<a href=""><img src="{{$v['options']['pic']}}" alt="" /></a>
								</div>
								<div class="search_shopping_erji1">
									<p class="search_shopping_erji11"><a href="">{{$v['name']}}</a></p>
									<p class="search_shopping_erji12">颜色：<em>{{$v['options']['color']}}</em>尺码：<em>{{$v['options']['size']}}</em></p>
								</div>
								<div class="search_shopping_erji2"><em>¥<i>{{$v['total']}}</i></em></div>
								<div class="search_shopping_erji3">
									<input type="hidden" name="danjia" id="" value="{{$v['price']}}" class="danjia"/>
									<a href="javascript:;" class="mul">-</a>
									<input type="text" name="shul" id="" value="{{$v['num']}}" class="shul"/>
									<a href="javascript:;" class="add">+</a>
									<input type="hidden" name="hiddenSid" id="" value="{{$k}}" class="hiddenSid"/>
								</div>	
								<p class="search_shopping_erji4"><a href="javascript:;" class="delOneCart">删除</a></p>
							</li>
							{{endforeach}}
						</ul>
						<div class="jiesuan">
							<span>共 <em>{{$cart}}</em> 件商品</span>
							<a href="{{U('MyCart/index')}}">去购物车结算</a>
						</div>						
					</div>
				{{else}}
					<div class="search_shopping_erji" style="height: 50px;text-align: center;">
						<p style="margin-top: 15px;color: #A9A9A9;">您的购物车中还没有任何商品</p>
					</div>
				{{endif}}
			</div>
			<!--购物车结束-->
		</div>	
		<!--搜索大区域结束-->
	</div>
	<!--搜索区域结束-->